<template>
    <div class="app-container">
        <el-form ref="elForm" :disabled="$route.query.isInfo" :model="formData" :rules="rules" size="medium"
            label-width="120px">
            <h2 style="text-align: center">年检规则</h2>
            <h4 class="form-header h4">基本信息</h4>
            <el-form-item label="非营运客车第" prop="licenseNum">
                <el-input v-model="one" placeholder="" clearable :style="{ width: '10%' }">
                </el-input> 年年检一次
            </el-form-item>
            <el-form-item label="非营运客车第" prop="brand">
                <el-input v-model="two" placeholder="" clearable :style="{ width: '10%' }">
                </el-input> 年年检一次
            </el-form-item>
            <el-form-item label="非营运客车超过" prop="brand">
                <el-input v-model="three" placeholder="" clearable :style="{ width: '10%' }">
                </el-input> 年 <el-input v-model="four" placeholder="" clearable :style="{ width: '10%' }">
                </el-input> 年年检一次
            </el-form-item>
            <el-form-item label="货车每" prop="brand">
                <el-input v-model="five" placeholder="" clearable :style="{ width: '10%' }">
                </el-input> 年年检一次
            </el-form-item>
            <el-col :span="24">
                <el-form-item label-width="0" style="text-align: center; margin-top: 30px">
                    <el-button v-if="!$route.query.isInfo" type="primary" @click="submitForm">提交</el-button>
                    <el-button :disabled="false" @click="resetForm">返回</el-button>
                </el-form-item>
            </el-col>
        </el-form>
    </div>
</template>
  
<script>
import { updatecarYearCheck, listRules } from "@/api/car/carRules.js";
export default {
    components: {},
    props: [],
    data() {
        return {
            rules: [],
            formData: {
                list: [
                    {
                        carCheckRuleId: 1,
                        value: ""
                    },
                    {
                        carCheckRuleId: 2,
                        value: ""
                    },
                    {
                        carCheckRuleId: 3,
                        value: ""
                    },
                    {
                        carCheckRuleId: 4,
                        value: ""
                    }
                ]
            },
            one: '',
            two: '',
            three: '',
            four: '',
            five: '',
            // driverSelectList: [],
        };
    },
    computed: {},
    watch: {},
    created() {
        this.getinfo();
    },
    mounted() { },
    methods: {
        getinfo() {
            listRules().then((response) => {
                this.one = response.data[0].value;
                this.two = response.data[1].value;
                this.three = response.data[2].value;
                this.four = response.data[3].value;
                this.five = response.data[4].value;

            });
        },

        submitForm() {
            this.$refs["elForm"].validate((valid) => {
                if (valid) {
                    let list = [
                        {
                            carCheckRuleId: 1,
                            value: this.one
                        },
                        {
                            carCheckRuleId: 2,
                            value: this.two
                        },
                        {
                            carCheckRuleId: 3,
                            value: this.three
                        },
                        {
                            carCheckRuleId: 4,
                            value: this.four
                        },
                        {
                            carCheckRuleId: 5,
                            value: this.five
                        },
                    ]

                    updatecarYearCheck(list).then((response) => {
                        this.$modal.msgSuccess("修改成功");
                        this.resetForm();
                    });
                }
            });
        },
        resetForm() {
            const obj = { path: "./inspectionRules" };
            this.$tab.closeOpenPage(obj);
        },
    },
};
</script>
  